function addRecommendWin(recommendId, title) {
	var addRecommendForm = new Ext.form.FormPanel({
		id : 'addRecommendForm',
		frame : true,
		layout : "form",
		buttonAlign : 'center',
		monitorValid : true,
		bodyBorder : false,
		fileUpload : true,// 上传文件设置为true
		reader : new Ext.data.JsonReader({
					success : 'success',
					root : 'data'
				}, [{
							name : 'id'
						}, {
							name : 'recommendTitle'
						}, {
							name : 'recommendType'
						}, {
							name : 'recommendPicPath'
						}, {
							name : 'recommendSourceType'
						}, {
							name : 'recommendComboSource'
						}, {
							name : 'recommendSource'
						}, {
							name : 'recommendTextSource'
						}, {
							name : 'startDate'
						}, {
							name : 'endDate'
						}, {
							name : 'recommendStatus'
						}, {
							name : 'recommendOrder'
						}, {
							name : 'createdDate'
						}, {
							name : 'createdName'
						}, {
							name : 'updatedDate'
						}, {
							name : 'updatedName'
						}, {
							name : 'goodsStatus'
						}, {
							name : 'goodsName'
						}]),
		items : [{
			border : false,
			style : {
				"textAlign" : 'center'
			},
			items : [{
				layout : 'column',
				border : false,
				items : [{
					layout : 'form',
					border : false,
					labelWidth : 60,
					defaults : {
						labelStyle : "text-align:right"
					},
					items : [{
						id : 'addRcommendGoods',
						fieldLabel : "<span style='color:#F00'>*</span>商品名称",
						xtype : 'goodsCmb',
						allowBlank : true,
						hiddenName : 'goodsId',
						showValue : true,
						existall : false,
						allowBlank:false,
						defaultFirstRow : 1,
						statusArr : [0, 1],
						listeners : {
							'select' : function(combo, records, eOpts) {
								var goods = records.json;
								// 设置图片
								if (goods.goodsPic) {
									Ext.getCmp('addRecommend_image').getEl().dom.src = goods.goodsPic;
								}

							}
						}
					}, {
						xtype : 'dataDictionaryCmb',
						anchor : '100%',
						fieldLabel : "<span style='color:#F00'>*</span>推荐类型",
						hiddenName : "recommendType",
						blankText : '推荐类型不能为空',
						editable : false,
						autoLoad : false,
						defaultFirstRow : 1,
						existall : false,
						dictionaryType : PmsUtil.recommend_type
					}, {
						xtype : "datetimefield",
						id : "addRecommendStartDate",
						name : "startDate",
						fieldLabel : "<span style='color:#F00'>*</span>开始时间",
						width : 195,
						editable : false,
						allowBlank : false,
						emptyText : "开始时间不能为空",
						format : 'Y-m-d H:i:s',
						altFormats : "Y/m/d|Ymd|Y-m-d H:i:s",// |区分多种日期格式
						listeners : {
							'select' : function() {
								Ext.getCmp('addRecommendEndDate')
										.setMinValue(this.getValue());
								
							}
						}
					}]
				}, {
					border : false,
					layout : 'form',
					defaults : {
						labelStyle : "text-align:right "
					},
					items : [{
								xtype : 'displayfield',
								anchor : '50%',
								fieldLabel : '是否热门',
								value : "否"
							}, {
								xtype : 'displayfield',
								anchor : '50%',
								fieldLabel : '状态',
								value : "不推荐"
							}, {
								width : 195,
								id : "addRecommendEndDate",
								xtype : "datetimefield",
								name : "endDate",
								fieldLabel : "<span style='color:#F00'>*</span>结束时间",
								allowBlank : false,
								editable : false,
								emptyText : "结束时间不能为空",
								format : 'Y-m-d H:i:s',
								altFormats : "Y/m/d|Ymd|Y-m-d",// |区分多种日期格式
								listeners : {
									'select' : function() {
										Ext.getCmp('addRecommendStartDate')
												.setMaxValue(this.getValue());
										

									}
								}
							}, {
								name : "recommendOrder",
								xtype : "numberfield",
								anchor : '100%',
								fieldLabel : "<span style='color:#F00'>*</span>排&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;序",
								allowBlank : false,
								blankText : '排序不能为空',
								allowDecimals : false,// 禁用小数
								allowNegative : false
								// 禁用负数
							}]
				}]
			}, {
				// 预览图片
				xtype : 'box',
				align : 'center',
				baseCls : "x-plain",
				id : 'addRecommend_image',
				autoEl : {
					width : 300,
					height : 200,
					tag : 'input',
					type : 'image',
					src : __ctxPath + "/images/monmonde.png",
					style : 'filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale);width:160px;height:160px;',
					onclick : 'clickHandler()',
					complete : 'off'
				}
			}]
		}],
		buttons : [{
					id : 'addOrUpdCommit',
					text : '确定',
					formBind : true,
					handler : function() {
						insertRecommend();
					}
				}, {
					text : "取消",
					handler : function() {
						addRecommendWindow.close();
					}
				}]
	});
	var addRecommendWindow = new Ext.Window({
				id : 'addRecommendWindow',
				closeAction : 'close',
				title : title,
				closable : true,
				plain : true,
				modal : true,
				draggable: false, // 不可拖动
				resizable:false,  // 不可调整
				width : 590,
				height : 340,
				buttonAlign : 'center',
				autoDestroy : true,
				layout : 'fit',
				items : [addRecommendForm]
			});
	return addRecommendWindow;
}

/**
 * 商品推荐突变点击事件
 */
function clickHandler() {
	var imageShow_box = Ext.getCmp("addRecommend_image");
	var subjectPicPath = imageShow_box.getEl().dom.src;
	window.open(subjectPicPath, '_blank');
}

/**
 * 显示推荐的商品图片
 */
function showAddRecommendImage(goodsId) {
	if (goodsId != null && goodsId != "undefined") {
		Ext.Ajax.request({
			deferredRender : false,
			url : __ctxPath + "/goodsManager/selectGoodsById",
			params : {
				goodsId : goodsId
			},
			waitTitle : "请稍候",
			waitMsg : "正在载入数据...",
			root : "data",
			success : function(response, options) {
				var jsonData = Ext.util.JSON.decode(response.responseText);
				if (jsonData.goodsPic) {
					Ext.getCmp('addRecommend_image').getEl().dom.src = jsonData.goodsPic;
				}
			}

		});
	}
}

/**
 * 添加商品推荐
 */
function insertRecommend() {
	var recommendForm = Ext.getCmp("addRecommendForm");
	if (recommendForm.getForm().isValid()) {
		Ext.Msg.confirm("提示框", "确认保存商品推荐信息吗？", function(button) {
					if (button == "yes") {
						recommendForm.getForm().submit({
							url : __ctxPath
									+ '/recommendManager/insertRecommend',
							waitTitle : "请稍候",
							waitMsg : "正在提交表单，请稍候......",
							failure : function(response, options) {
								var jsonData = Ext.util.JSON
										.decode(options.response.responseText);
								Ext.MessageBox.show({
											title : "错误提示",
											msg : jsonData.data,
											buttons : Ext.MessageBox.OK,
											icon : Ext.MessageBox.ERROR
										});
							},
							success : function(response, options) {
								var jsonData = Ext.util.JSON
										.decode(options.response.responseText);
								Ext.MessageBox.show({
											title : "提示信息",
											msg : jsonData.data,
											buttons : Ext.MessageBox.OK,
											icon : Ext.MessageBox.INFO
										});
								Ext.getCmp("addRecommendWindow").close();
								var gridPanel = Ext
										.getCmp("recommendManagerGrid");
								if (typeof(gridPanel) != 'undefined') {
									gridPanel.store.reload();
								}
							}
						});

					}

				});
	}
}
